package com.wyp.springbootinit.config;

import com.qiniu.util.Auth;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 4413
 */
@Configuration
@ConfigurationProperties(prefix = "kodo.client")
@Data
public class UptokenConfig {
    /**
     * accessKey
     */
    private String accessKey;

    /**
     * secretKey
     */
    private String secretKey;

    /**
     * 桶名
     */
    private String bucket;

    @Bean
    public String upToken() {
        Auth auth = Auth.create(accessKey, secretKey);
        return auth.uploadToken(bucket, null, 31104000, null);
    }

    @Bean
    public Auth getAuth() {
        return Auth.create(accessKey, secretKey);
    }
}
